import { getScatterData } from '@/api'

/* 封装包裹数组的方法 */
function wrapperArr(obj, key) {
    return obj && obj[key] ? obj[key] : [];
}

/* 封装包裹对象的方法 */
function wrapperObj(obj,key) {
    return obj && obj[key] ? obj[key] : [];
}


export default {
    data() {
        return {
            dataCity:[],
            dataPoint:{},
        }
    },
    computed: {
        scatterData() {
            var arr = [];
            this.dataCity.forEach(item => {
                var obj = {};
                obj.name = item.name;
                obj.value = [...this.dataPoint[item.name],item.value]
                console.log(obj);
            })
            return arr;
        }
    },
    async mounted() {
        let res = await getScatterData();
        this.dataCity = wrapperArr(res,'data');
        this.dataPoint = wrapperObj(res,'geo');
        console.log(this.dataCity);
        console.log(this.dataPoint);
        console.log(this.scatterData)
    }
}